Skip to content

ld/dwarf: increase includestack from 16 to 64#143

Merged
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd
May 22, 2026
Merged

ld/dwarf: increase includestack from 16 to 64#143
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd

Conversation

@staalmannen

Copy link
Copy Markdown
Owner

APE headers have deep transitive include chains that exceed the original Go-era limit of 16. 64 is enough for real-world nesting.

https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs

APE headers have deep transitive include chains that exceed the
original Go-era limit of 16. 64 is enough for real-world nesting.

https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen staalmannen merged commit 0613e19 into main May 22, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request increases the size of the includestack array from 16 to 64 in sys/src/cmd/ld/dwarf.c to handle deeper include hierarchies. The review feedback suggests avoiding the use of a magic number by using a named constant or the nelem() macro and recommends increasing the limit further to 128 to ensure safety for extremely deep include chains.

Comment thread sys/src/cmd/ld/dwarf.c
int file;
vlong line;
} includestack[16];
} includestack[64];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Increasing the stack size to 64 addresses the immediate issue, but using a hardcoded magic number is risky if bounds checks elsewhere in the code (e.g., in addhistfile) are not updated to match. It is recommended to use a named constant or the nelem() macro to ensure the array size and its bounds checks remain in sync. Additionally, given the minimal memory impact, a larger limit like 128 might be safer for extremely deep include chains.

} includestack[128];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants